package 代码coding题OR模拟题;
import java.util.HashSet;
public class leetcode804摩斯密码 {
		public static void  main(String []args) {
			String words[] = {"gin", "zen", "gig", "msg"};
			System.out.println(solution(words));
		}
static String [] compareTable = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
		public static int solution(String []words) {
		
//			int ans  = 0;
			if(words.length == 1) {
				return 1;
			}
			HashSet<String> set = new HashSet<>();
			for(String s : words) {
				if(set.contains(translator(s))) {
					set.remove(s);
				}
				else {
					set.add(s);
				}
			}
				
//			return ans;
			return set.size();
		}
		public static String translator(String s) {
			StringBuilder str = new StringBuilder();
			for(int  i = 0 ;i < s.length();i++) {
					str.append(compareTable[s.charAt(i) - 'a']);
				}
			
			return str.toString();
		}
}
